<template>
  <div>
    <el-card>
      <el-table :data="taskList" style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="任务 ID">
                <span>{{ props.row.id }}</span>
              </el-form-item>
              <el-form-item label="任务名称">
                <span>{{ props.row.name }}</span>
              </el-form-item>
              <el-form-item label="任务类型">
                <span>{{ props.row.typeClassify==1?'日常任务':'一次性任务' }}</span>
              </el-form-item>
              <el-form-item label="任务介绍">
                <span>{{ props.row.introduce }}</span>
              </el-form-item>
              <el-form-item label="确认方式">
                <span>{{ props.row.accomplishType==1?'主账号确认':'次级账号确认' }}</span>
              </el-form-item>
              <el-form-item label="需求等级">
                <span>{{ props.row.prepositionLevel }}</span>
              </el-form-item>
              <el-form-item label="经验奖励">
                <span>{{ props.row.awardLevel }}</span>
              </el-form-item>
              <el-form-item label="金币奖励">
                <span>{{ props.row.awardMoney }}</span>
              </el-form-item>
              <el-form-item label="经验惩罚">
                <span>{{ props.row.punishmentLevel }}</span>
              </el-form-item>
              <el-form-item label="金币惩罚">
                <span>{{ props.row.punishmentMoney }}</span>
              </el-form-item>
              <el-form-item label="任务限时" v-if="props.row.limitTime!=null">
                <span>{{ props.row.limitTime }}小时</span>
              </el-form-item>
              <el-form-item label="任务领取时间">
                <span>
                  {{props.row.receiveCreateTime}}
                </span>
              </el-form-item>
              <el-form-item label="任务完成时间">
                <span>
                  {{props.row.receiveFinishTime}}
                </span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="任务 ID" prop="id"></el-table-column>
        <el-table-column label="任务名称" prop="name"></el-table-column>
        <el-table-column label="任务类型">
          <template slot-scope="pro">
            <span>{{pro.row.typeClassify==1?'日常任务':'一次性任务'}}</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum"
        :page-sizes="[2, 5, 10]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>


<style lang="less" scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>

<script>
import { secondaryGetCompletedTask } from "@/utils/SecondaryApi";
export default {
  // props: [
  //   'completedTaskRes'
  // ],
  data() {
    return {
      queryInfo: {
        query: "",
        // 当前页数
        pageNum: 1,
        // 每页显示多少数据
        pageSize: 10,
        isType: 1,
      },
      taskList: [],
      total: 0,
    };
  },
  created() {
    this.getTaskList();
  },
  methods: {
    async getTaskList() {
      const { data: res } = await secondaryGetCompletedTask(this.queryInfo);
      if (res.meta.status !== 200) {
        return this.$message.error("获取任务列表失败");
      }
      this.taskList = res.data.list;
      this.total = res.data.total;
    },

    isReceive(flag) {
      return flag == 1;
    },
    handleSizeChange(newSize) {
      console.log(newSize);
      this.queryInfo.pageSize = newSize;
      this.getTaskList();
    },
    // 监听 页码值 改变事件
    handleCurrentChange(newSize) {
      // console.log(newSize)
      this.queryInfo.pageNum = newSize;
      this.getTaskList();
    },
    finishTaskDisabled(flag) {
      return flag === 1;
    },
  },
};
</script>